package com.mihe.core.web.page;


import cn.hutool.core.util.ObjectUtil;
import com.mihe.core.utils.ServletUtils;
import com.mihe.core.utils.StringUtils;

/**
 * 表格数据处理
 *
 * @author ruoyi
 */
public class TableSupport {
    /**
     * 当前记录起始索引
     */
    public static final String PAGE_NUM = "pageNum";

    /**
     * 每页显示记录数
     */
    public static final String PAGE_SIZE = "pageSize";


    /**
     * 封装分页对象
     */
    public static PageDomain getPageDomain() {
        PageDomain pageDomain = new PageDomain();
        Integer pageNum=ServletUtils.getParameterToInt(PAGE_NUM);
        Integer pageSize=ServletUtils.getParameterToInt(PAGE_SIZE);
        if (ObjectUtil.isEmpty(pageNum))
            pageNum=pageDomain.getPageNum();
        if(ObjectUtil.isEmpty(pageSize))
            pageSize=pageDomain.getPageSize();
        pageDomain.setPageNum(pageNum);
        pageDomain.setPageSize(pageSize);
        return pageDomain;
    }

    public static PageDomain buildPageRequest() {
        return getPageDomain();
    }
}
